package com.cml.getway.core;

import com.cml.getway.common.config.DynamicConfigManager;
import com.cml.getway.core.discovery.RegistryManager;

/**
 * 姓名：陈茂林
 * 时间：2023/12/20
 * 描述：
 */
public class BootStrap {
    public static void main(String[] args) {
        // 加载配置文件
        GetwayConfig getwayConfig = GetwayConfigLoader.getInstance().load(args);

        //插件初始化

        //初始化注册中心
        try {
            RegistryManager.getInstance().initialized(getwayConfig);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        //启动容器
        GetwayContainer getwayContainer=new GetwayContainer(getwayConfig);
        getwayContainer.start();
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                getwayContainer.shutdown();
            }
        }));
    }
}
